# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Michael Mason <ms13sp@gmail.com>
pkgname=mailx
# tracks debians cvs checkouts
_date=20220412
_version=8.1.2
pkgver=${_version}_git$_date
pkgrel=1
pkgdesc="commandline utility for sending email"
url="http://www.opengroup.org/onlinepubs/007908799/xcu/mailx.html"
arch="all"
license="BSD-4-Clause-UC"
makedepends="libbsd-dev liblockfile-dev"
subpackages="$pkgname-doc"
source="http://deb.debian.org/debian/pool/main/b/bsd-mailx/bsd-mailx_$_version-0.${_date}cvs.orig.tar.xz
	http://deb.debian.org/debian/pool/main/b/bsd-mailx/bsd-mailx_$_version-0.${_date}cvs-1.debian.tar.xz
	00-Makefiles.patch
	02-Base-fixes-1.patch
	CCEQ.patch
	"
builddir="$srcdir/bsd-mailx-$_version-0.${_date}cvs.orig"
options="suid !check" # No testsuite

prepare() {
	default_prepare
	# debian keeps their patchset in their own folder
	while read -r patch; do
		# put these top level to modify them
		echo "$patch" | grep -q 00-Makefiles && continue
		echo "$patch" | grep -q 02-Base-fixes-1 && continue

		patch -Np1 < "$srcdir"/debian/patches/"$patch"
	done < "$srcdir"/debian/patches/series
}

build() {
	make PROG=mail
}

package() {
	mkdir -p "$pkgdir"/usr/bin
	mkdir -p "$pkgdir"/usr/share/man/man1
	mkdir -p "$pkgdir"/usr/share/misc
	mkdir -p "$pkgdir"/etc
	make DESTDIR="$pkgdir" install
}

sha512sums="
acee80e49fbac85dfaa48d885dd310a056a1418c6e3b02ee9f30441a34c104b134fb7c47cac91a1b2359d3d3cba0cf026d9cdf51f659b8c172100d7f98156203  bsd-mailx_8.1.2-0.20220412cvs.orig.tar.xz
8794d8a41ec86012f4e74509f489afa8dcb624a17a6bc779024b2bb6eed8a7a86826785601bd295147641cd26f4288ec73aa8c3a2451b35b41fbc682f91c157f  bsd-mailx_8.1.2-0.20220412cvs-1.debian.tar.xz
030ba8fe900d42c0a780109a0b21d2eb040d182dd1febed0e079e1291f0cb3d65472e00ef557f5ea8a96122eef68b17ec00645aaf9b07355bbd44e5ee1139b81  00-Makefiles.patch
a8c975196468015e2e57b2848c17c0a827c18db9d04b019d3912d3f0a40d379f7f115d6b1db32f129f4faf171e99eb746dcfbbc157329ad11fde1a1b8415175e  02-Base-fixes-1.patch
c285c25620bfe5ca07fc1d068c40dea1f1a980cce1c4dcd7dd4f6de0d492e9fe8f968ef818c630aa1d95beed269e9b9464a53a5ff1af54cdaf3e0bab92a76d3f  CCEQ.patch
"
